#!/bin/bash
OK=0
WARN=1
CRITICAL=2
UNKNOWN=3
PATH="/bin:/sbin:/usr/bin:/usr/sbin"

Ok_name=''
Fail_name=''
Judge_C=0
PWDP=/usr/lib64/nagios/plugins
DiskmonitorP=$PWDP/diskmonitor
c_host=`hostname -s`
for i in `grep $c_host $DiskmonitorP| awk -F ';' '{print $2}'`
do
	#check SL5/SL6
	TT=`uname -a |awk '{print $3}'|awk -F '.' '{print $6}'`
	if [ "$TT" != "el6" ]
	then
        	Temp=`/sbin/tune4fs -l $i|grep stat|awk -F ":" '{print $2}'`
	else
		Temp=`/sbin/tune2fs -l $i|grep stat|awk -F ":" '{print $2}'`
	fi
	
        if [ "$Temp" = "         clean" ]
        then 
                Ok_name="${Ok_name} ${i}"
        else
                Judge_C=1
                Fail_name="${Fail_name} ${i}"
        fi

done
if [ $Judge_C -eq 1 ]
then
        echo "$Fail_name  wrong"
        exit $CRITICAL
else
        echo " gluster:all disk stat are OK "
        exit $OK
fi
